package beans;

import sqlInject.Payload;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by shuaidong on 2017/7/2.
 */
public class OrdinaryPayload {
    private String pageNormalPayload;

    private String pageAbNormalPayload;

    private static List<OrdinaryPayload> ordinaryPayloadList = null;
    private static BufferedReader bufferedReader = new BufferedReader(new InputStreamReader( Payload.class.getClassLoader().
            getResourceAsStream("ordinaryInjectionPayload.txt")));

    public static List<OrdinaryPayload> getInstanceOrdinaryPayloadList(){
        if ( null == ordinaryPayloadList){
            ordinaryPayloadList = new ArrayList<OrdinaryPayload>();
            try {
                String line = null;
                while ((line = bufferedReader.readLine())!= null&&!line.trim().equals("")){
                    String[] strings = line.split("\\|");
                    OrdinaryPayload ordinaryPayload = new OrdinaryPayload(strings[0],strings[1]);
                    ordinaryPayloadList.add(ordinaryPayload);
                }
                bufferedReader.close();
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return ordinaryPayloadList;
    }

    public OrdinaryPayload(String pageNormalPayload, String pageAbNormalPayload) {
        this.pageNormalPayload = pageNormalPayload;
        this.pageAbNormalPayload = pageAbNormalPayload;
    }

    public String getPageNormalPayload() {
        return pageNormalPayload;
    }

    public void setPageNormalPayload(String pageNormalPayload) {
        this.pageNormalPayload = pageNormalPayload;
    }

    public String getPageAbNormalPayload() {
        return pageAbNormalPayload;
    }

    public void setPageAbNormalPayload(String pageAbNormalPayload) {
        this.pageAbNormalPayload = pageAbNormalPayload;
    }

    public static List<OrdinaryPayload> getOrdinaryPayloadList() {
        return ordinaryPayloadList;
    }

    public static void setOrdinaryPayloadList(List<OrdinaryPayload> ordinaryPayloadList) {
        OrdinaryPayload.ordinaryPayloadList = ordinaryPayloadList;
    }
}
